
var maxCode = function(luckyNumber,instructions){

  let position =0;
  let max = 0;

  const positions = [];

  positions.push(position)
  for(let instru of instructions){
    let steps = instru
    if(steps== luckyNumber){
      steps>0?steps++:steps--
    }
    if(instru>0){
      position+=steps
    }else{
      position -= Math.abs(steps)
    }
    positions.push(position)
    
    max = Math.max(max,position)
  }

  console.log(max)
  console.log(positions)

}

var luckyNumber =-5
var arrays = [-5,1,6,0,-7];

maxCode(luckyNumber,arrays)
